package com.pay.dextest;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class FileUtil {
    public static synchronized String readFile(String path) {
        String res = "";
        File file = new File(path);
        if (file.exists()) {
            try {
                FileInputStream fit = new FileInputStream(path);
                BufferedReader br = new BufferedReader(new InputStreamReader(fit));
                StringBuilder sb = new StringBuilder();
                String line;
                while ((line = br.readLine()) != null) {
                    sb.append(line);
                }
                br.close();
                res = sb.toString();
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return res;
    }

}
